package com.haiqi.modules.map.service;

import com.github.pagehelper.PageInfo;
import com.haiqi.common.bean.PageBean;
import com.haiqi.common.persistence.dao.ServerMapper;
import com.haiqi.common.persistence.entity.Server;
import com.haiqi.common.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/8/16 0016.
 */
@Service
public class ServerService {
    @Autowired
    private ServerMapper serverMapper;

    public PageInfo<Server> getDataList(Server server, PageBean page){
        PageUtils.generatePage(page);
        List<Server> dataList = serverMapper.getServerList(server);
        PageInfo<Server> serverList = new PageInfo<Server>(dataList);
        for (Server server1 : serverList.getList()) {
            if(server1.getType().equals("point"))
            {
                String[] str=server1.getWkt().substring(6,server1.getWkt().length()-1).split(" ");
                server1.setLon(str[0]);
                server1.setLat(str[1]);
            }

        }
        return serverList;
    }
}
